package com.taobaolite.index;

import com.taobaolite.item.Item;
import com.taobaolite.item.ItemBody;
import com.taobaolite.item.ItemRepository;
import com.taobaolite.tag.Tag;
import com.taobaolite.tag.TagRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
@AllArgsConstructor
public class IndexService {

    private final ItemRepository itemRepo;
    private final TagRepository tagRepo;

    public List<ItemBody> getHotItems() {

        List<Item> itemList = itemRepo.findAll();

        // Apply item filter here

        return itemList.stream().map(ItemBody::new).collect(Collectors.toList());
    }

    public List<Tag> getTags() {
        return tagRepo.findAll();
    }
}
